<?
	$objConnect = mysql_connect("localhost","root","");
	$objDB = mysql_select_db("db_sipemenang");

	$strIdBuktiPengiriman = $_POST["sIdBuktiPengiriman"];
	$strIdPemesanan = $_POST["sIdPemesanan"];

	/*** Check Id Transfer Exists ***/
	$strSQL = "SELECT * FROM bukti_pengiriman WHERE id_buktipengiriman = '".$strIdBuktiengiriman."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	if($objResult)
	{
		$arr['StatusID'] = "0"; 
		$arr['Error'] = "ID Pengriminan Exists!";	
		echo json_encode($arr);
		exit();
	}

	/*** Check ID Order Exists ***/
	$strSQL = "SELECT * FROM bukti_pengiriman WHERE id_pemesanan = '".$strIdPemesanan."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	if($objResult)
	{
		$arr['StatusID'] = "0"; 
		$arr['Error'] = "ID Pemesanan Exists!";	
		echo json_encode($arr);
		exit();
	}
	
	/*** Insert ***/
	$strSQL = "INSERT INTO bukti_pengiriman (id_pengiriman,id_pemesanan) 
		VALUES (
			'".$strIdBuktiPengiriman."',
			'".$strIdPemesanan."'
			)
		";

	$objQuery = mysql_query($strSQL);
	if(!$objQuery)
	{
		$arr['StatusID'] = "0"; 
		$arr['Error'] = "Cannot save data!";	
	}
	else
	{
		$arr['StatusID'] = "1"; 
		$arr['Error'] = "";	
	}
	
	mysql_close($objConnect);
	
	echo json_encode($arr);
?>
